package learn.demo2;

import java.util.ArrayList;

public class Manager extends User {

    public Manager() {
    }
    public Manager(String name, int money) {
        super(name, money); //父类
    }
    public ArrayList<Integer> send(int totalMoney,int count){

        ArrayList<Integer> redList = new ArrayList<>();//需要一个集合.用来存储若干个红包的金额
        int leftMoney=super.getMoney();//群主剩下的钱
        if (totalMoney>leftMoney){
            System.out.println("余额不足");
            return redList;
        }
        super.setMoney(leftMoney-totalMoney);//扣钱

        int avg = totalMoney/count;
        int mod = totalMoney % count;
        //除不开的放在最后一个中
        for (int i = 0; i < count-1; i++) {
            redList.add(avg);
        }
        int last = avg+mod;
        redList.add(last);
        return redList;

    }



}
